<template>
    <div>
      <h2>store测试</h2>
      <h2>{{ $store.state.counter}}</h2>
      <button @click="add()"> 加法</button>
      <p>----------------------------</p>
      <store-demo2></store-demo2>
      <p>----------------------------</p>
      <h2>{{ $store.getters.sumCounterAndNum }}</h2>
      <h2>{{ $store.getters.sum2CounterAndNum }}</h2>
      <h2>{{ $store.getters.sum3CounterAndNum(10) }}</h2>
    </div>
</template>

<script>
  import storeDemo2 from '../../components/store/storeDemo2'
//引入静态变量
  import {INCREMENT,INCREMENTBYCOUNT,INCREMENTBYPARAM} from  '../../components/store/cons-type'
    export default {
      name: "storeDemo",
      components: {
        storeDemo2,
      },
      methods: {
        add(){
          this.$store.commit(INCREMENT)
          this.$store.commit(INCREMENTBYCOUNT,10)
          this.$store.commit('incrementByAsync')
          this.$store.commit({
            type: INCREMENTBYPARAM,
            count: 15,
            success: function (result) {
              //回调
              console.log(result)
            }
          })
        }
      }
    }
</script>

<style scoped>

</style>
